package com.smart.modules.genealogy.service.impl;

import com.smart.system.common.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.smart.modules.genealogy.mapper.GenealogyMapper;
import com.smart.modules.genealogy.domain.Genealogy;
import com.smart.modules.genealogy.service.IGenealogyService;

/**
 * 家谱Service业务层处理
 */
@Service
public class GenealogyServiceImpl implements IGenealogyService
{
    @Autowired
    private GenealogyMapper genealogyMapper;

    /**
     * 查询家谱
     *
     * @param genealogyId 家谱主键
     * @return 家谱
     */
    @Override
    public Genealogy selectGenealogyByGenealogyId(Long genealogyId)
    {
        return genealogyMapper.selectGenealogyByGenealogyId(genealogyId);
    }

    /**
     * 查询家谱列表
     *
     * @param genealogy 家谱
     * @return 家谱
     */
    @Override
    public IPage<Genealogy> selectGenealogyList(IPage<Genealogy> page,Genealogy genealogy)
    {
        return genealogyMapper.selectGenealogyList(page,genealogy);
    }

    /**
     * 新增家谱
     *
     * @param genealogy 家谱
     * @return 结果
     */
    @Override
    public int insertGenealogy(Genealogy genealogy)
    {
        genealogy.setCreateTime(DateUtils.getNowDate());
        return genealogyMapper.insertGenealogy(genealogy);
    }

    /**
     * 修改家谱
     *
     * @param genealogy 家谱
     * @return 结果
     */
    @Override
    public int updateGenealogy(Genealogy genealogy)
    {
        genealogy.setUpdateTime(DateUtils.getNowDate());
        return genealogyMapper.updateGenealogy(genealogy);
    }

    /**
     * 批量删除家谱
     *
     * @param genealogyIds 需要删除的家谱主键
     * @return 结果
     */
    @Override
    public int deleteGenealogyByGenealogyIds(Long[] genealogyIds)
    {
        return genealogyMapper.deleteGenealogyByGenealogyIds(genealogyIds);
    }

    /**
     * 删除家谱信息
     *
     * @param genealogyId 家谱主键
     * @return 结果
     */
    @Override
    public int deleteGenealogyByGenealogyId(Long genealogyId)
    {
        return genealogyMapper.deleteGenealogyByGenealogyId(genealogyId);
    }
}
